package com.mediacloud.app.newsmodule.fragment.imagetext;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.mediacloud.app.assembly.util.Utility;
import com.mediacloud.app.model.component.ComponentItem;
import com.mediacloud.app.model.news.ArticleItemReciver;
import com.mediacloud.app.newsmodule.R;
import com.mediacloud.app.newsmodule.newsdetail_component.NewsDetailComponentUtils;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;

/**
 * Created by Yoake on 2018/3/5.
 */

public class MicroImageTextDetailFragment extends ImageTextDetailFragment2 {
    public ArrayList<ComponentItem> components;

    @Override
    public void setMicroLiveWebBackGround() {
        View scrollContent = Utility.findViewById(mRootView, R.id.scrollContent);
        if (!fromShanShiPin) {
            scrollContent.setBackgroundColor(Color.WHITE);
            mWebView.setBackgroundColor(Color.WHITE);
        }
    }

    @Override
    protected void getDetail() {

    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        components =getArguments().getParcelableArrayList("COMPONENT_LIST");
        showHTMLData(article.getContent());
        setMediaContent();
        ViewStub viewStub = mRootView.findViewById(R.id.vsRelate);
        viewStub.inflate();
        ViewGroup relateLayout = mRootView.findViewById(R.id.relateLayout);
        layoutRootTitleInfo.setVisibility(View.GONE);
        NewsDetailComponentUtils.addComponentList(relateLayout, components, article, getActivity(), getChildFragmentManager(), 1, this);

    }

    public void setData(ArticleItemReciver data) {
        EventBus.getDefault().removeStickyEvent(data);
    }

    /**
     * 东西没变只是改变了一下间距之类的
     *
     * @return
     */
    @Override
    public int getLayoutResID() {
        return R.layout.imagetext_detailfragment_mic2;
    }

    @Override
    public void initView() {
        super.initView();
        if (fromShanShiPin) {
            mRootView.setBackgroundColor(Color.BLACK);
            mWebView.setBackgroundColor(Color.BLACK);
        }
    }
}